/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package metodo;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
/**
 *
 * @author Jorge
 */
public class ap {
    Connection conexion;
    

    public boolean conectar() {

        try {
            DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
            String BaseDeDatos = "jdbc:oracle:thin:@localhost:1521:XE";
            conexion = DriverManager.getConnection(BaseDeDatos, "PROYECTO_NUTRI", "proyecto");
            if (conexion != null) {
                System.out.println("Conexion exitosa a esquema BASE");
                return true;
            } else {
                System.out.println("Conexion fallida");
            }
        } catch (Exception e) {
            System.out.println("error: " + e);
        }
        return false;
    }
    public ResultSet consulta(String a, String b) {
        ResultSet rs = null;
        try {
            String sql = "Select * from USUARIO where USUARIO='" + a + "' and PASSWORD='" + b + "'";
            if (conectar()) {
                Statement stt = conexion.createStatement();
                rs = stt.executeQuery(sql);
                return rs;
            } else {
                return rs;
            }
        } catch (Exception ae) {
            return rs;
        }

    }
    public ResultSet paciente() {
        ResultSet rs = null;
        try {
            String sql = "Select * from USUARIO";
            if (conectar()) {
                Statement stt = conexion.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
                rs = stt.executeQuery(sql);
                return rs;
            } else {
                return rs;
            }
        } catch (Exception ae) {
            return rs;
        }

    }
    
}
